package com.credit.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.credit.common.ServerResponse;
import com.credit.pojo.administrative;
import com.credit.pojo.branch;
import com.credit.pojo.brand;
import com.credit.pojo.copyright;
import com.credit.pojo.creditLoan;
import com.credit.pojo.enterpriseHonor;
import com.credit.pojo.enterpriseInformation;
import com.credit.pojo.framework;
import com.credit.pojo.historic;
import com.credit.pojo.job;
import com.credit.pojo.judicial;
import com.credit.pojo.managementSystem;
import com.credit.pojo.patent;
import com.credit.pojo.patentType;
import com.credit.pojo.publicWelfare;
import com.credit.pojo.seniorExecutive;
import com.credit.pojo.shareholder;
import com.credit.pojo.violationOperation;
import com.credit.service.IPublicCreditService;
import com.credit.utlis.ImgUpload;

/**
 * 公共信用信息
 * @author Administrator
 *
 */
@CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
@RestController
@Controller
public class PublicCreditConteoller {

	@Autowired
	private IPublicCreditService publicCreditService;
	
	
	
	
	/**
	 * 查看企业信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectEnterpriseInformation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectEnterpriseInformation(int id) {
		
		return publicCreditService.selectEnterpriseInformation(id);
	}
	
	
	
	
	/**
	 * 增加企业信息
	 * @param e
	 * @return
	 */
	@RequestMapping(value = "addEnterpriseInformation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addEnterpriseInformation(enterpriseInformation e) {
		
		return publicCreditService.insertEnterpriseInformation(e);
	}
	
	
	
	/**
	 * 修改企业信息
	 * @param e
	 * @return
	 */
	@RequestMapping(value = "upEnterpriseInformation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upEnterpriseInformation(enterpriseInformation e) {
		
		return publicCreditService.updateEnterpriseInformation(e);
	}
	
	
	
	
	
	/**
	 * 查看股东信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectShareholder.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectShareholder(int id) {
		
		return publicCreditService.selectShareholder(id);
	}
	
	
	
	/**
	 * 增加股东信息
	 * @param s
	 * @return
	 */
	@RequestMapping(value = "addShareholder.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addShareholder(shareholder s) {
		
		return publicCreditService.insertShareholder(s);
	}
	
	
	/**
	 * 修改股东信息
	 * @param s
	 * @return
	 */
	@RequestMapping(value = "upShareholder.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upShareholder(shareholder s) {
		
		return publicCreditService.updateShareholder(s);
	}
	
	
	/**
	 * 删除股东信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delShareholder.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delShareholder(Integer id) {
		
		return publicCreditService.deleteShareholder(id);
	}
	
	
	
	
	
	/**
	 * 查看历史变更
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectHistoric.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectHistoric(int id) {
		
		return publicCreditService.selectHistoric(id);
	}
	
	
	
	/**
	 * 增加历史变更
	 * @param h
	 * @return
	 */
	@RequestMapping(value = "addHistoric.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addHistoric(historic h) {
		
		return publicCreditService.insertHistoric(h);
	}
	
	
	/**
	 * 修改历史变更
	 * @param h
	 * @return
	 */
	@RequestMapping(value = "upHistoric.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upHistoric(historic h) {
		
		return publicCreditService.updateHistoric(h);
	}
	
	
	/**
	 * 删除历史变更
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delHistoric.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delHistoric(Integer id) {
		
		return publicCreditService.deleteHistoric(id);
	}
	
	
	
	
	
	/**
	 * 查看分支结构
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectBranch.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectBranch(int id) {
		
		return publicCreditService.selectBranch(id);
	}
	
	
	
	/**
	 * 增加分支结构
	 * @param b
	 * @return
	 */
	@RequestMapping(value = "addBranch.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addBranch(branch b) {
		
		return publicCreditService.insertBranch(b);
	}
	
	/**
	 * 修改分支结构
	 * @param b
	 * @return
	 */
	@RequestMapping(value = "upBranch.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upBranch(branch b) {
		
		return publicCreditService.updateBranch(b);
	}
	
	
	/**
	 * 删除分支结构
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delBranch.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delBranch(Integer id) {
		
		return publicCreditService.deleteBranch(id);
	}
	
	
	/**
	 * 查看组织机构
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectFramework.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectFramework(int id) {
		
		return publicCreditService.selectFramework(id);
	}
	
	
	/**
	 * 增加组织机构
	 * @param f
	 * @param photo
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "addFramework.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addFramework(framework f,@RequestParam(value = "file", required = false) MultipartFile photo,HttpServletRequest request) {
		try {
			String url = ImgUpload.PictureUpload(photo, request);
			f.setUrl(url);
		} catch (IOException e) {
		
			e.printStackTrace();
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		return publicCreditService.insertFramework(f);
	}
	
	
	
	/**
	 * 修改组织机构
	 * @param f
	 * @param photo
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "upFramework.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upFramework(framework f,@RequestParam(value = "file", required = false) MultipartFile photo,HttpServletRequest request) {
		try {
			String url = ImgUpload.PictureUpload(photo, request);
			f.setUrl(url);
		} catch (IOException e) {
			
			e.printStackTrace();
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		return publicCreditService.updateFramework(f);
	}
	
	
	
	
	
	/**
	 * 查看管理制度
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectManagementSystem.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectManagementSystem(int id) {
		
		return publicCreditService.selectManagementSystem(id);
	}
	
	
	/**
	 * 增加管理制度
	 * @param m
	 * @return
	 */
	@RequestMapping(value = "addManagementSystem.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addManagementSystem(managementSystem m) {
		
		return publicCreditService.insertManagementSystem(m);
	}
	
	/**
	 * 修改管理制度
	 * @param m
	 * @return
	 */
	@RequestMapping(value = "upManagementSystem.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upManagementSystem(managementSystem m) {
		
		return publicCreditService.updateManagementSystem(m);
	}
	
	/**
	 * 删除管理制度
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delManagementSystem.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delManagementSystem(Integer id) {
		
		return publicCreditService.deleteManagementSystem(id);
	}
	
	
	
	/**
	 * 显示高管人员
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectSeniorExecutive.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectSeniorExecutive(int id) {
		
		return publicCreditService.selectSeniorExecutive(id);
	}
	
	
	/**
	 * 增加高管人员
	 * @param s
	 * @return
	 */
	@RequestMapping(value = "addSeniorExecutive.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addSeniorExecutive(seniorExecutive s) {
		
		return publicCreditService.insertSeniorExecutive(s);
	}
	
	/**
	 * 修改高管人员
	 * @param s
	 * @return
	 */
	@RequestMapping(value = "upSeniorExecutive.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upSeniorExecutive(seniorExecutive s) {
		
		return publicCreditService.updateSeniorExecutive(s);
	}
	
	
	/**
	 * 删除高管人员
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delSeniorExecutive.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delSeniorExecutive(Integer id) {
		
		return publicCreditService.deleteSeniorExecutive(id);
	}
	
	
	
	
	
	/**
	 * 显示从业人员
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectJob.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectJob(int id) {
		
		return publicCreditService.selectJob(id);
	}
	
	
	/**
	 * 增加从业人员
	 * @param j
	 * @return
	 */
	@RequestMapping(value = "addJob.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addJob(job j) {
		
		return publicCreditService.insertJob(j);
	}
	
	/**
	 * 修改从业人员
	 * @param j
	 * @return
	 */
	@RequestMapping(value = "upJob.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upJob(job j) {
		
		return publicCreditService.updateJob(j);
	}
	
	
	
	
	
	/**
	 * 显示商标
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectBrand.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectBrand(int id) {
		
		return publicCreditService.selectBrand(id);
	}
	
	
	/**
	 * 增加商标
	 * @param b
	 * @param photo
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "addBrand.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addBrand(brand b,@RequestParam(value = "file", required = false) MultipartFile photo,HttpServletRequest request) {
		try {
			String url = ImgUpload.PictureUpload(photo, request);
			b.setUrl(url);
		} catch (IOException e) {
			
			e.printStackTrace();
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		return publicCreditService.insertBrand(b);
	}
	
	
	
	/**
	 * 修改商标
	 * @param b
	 * @param photo
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "upBrand.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upBrand(brand b,@RequestParam(value = "file", required = false) MultipartFile photo,HttpServletRequest request) {
		try {
			String url = ImgUpload.PictureUpload(photo, request);
			b.setUrl(url);
		} catch (IOException e) {
			
			e.printStackTrace();
		} catch (Exception e) {
		
			e.printStackTrace();
		}
		return publicCreditService.updateBrand(b);
	}
	
	
	
	
	
    /**
     * 删除商标
     * @param id
     * @return
     */
	@RequestMapping(value = "delBrand.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delBrand(int id) {
		
		return publicCreditService.deleteBrand(id);
	}
	
	
	
	
	
	/**
	 * 显示专利
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectPatent.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectPatent(int id) {
		
		return publicCreditService.selectPatent(id);
	}
	
	
	/**
	 * 增加专利
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addPatent.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addPatent(patent p) {
		
		return publicCreditService.insertPatent(p);
	}
	
	/**
	 * 修改专利
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upPatent.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upPatent(patent p) {
		
		return publicCreditService.updatePatent(p);
	}
	
	
	/**
	 * 删除专利
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delPatent.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delPatent(int id) {
		
		return publicCreditService.deletePatent(id);
	}
	
	
	
	
	
	
	/**
	 * 显示专利分类
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectPatentType.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectPatentType(int id) {
		
		return publicCreditService.selectPatentType(id);
	}
	
	
	/**
	 * 增加专利分类
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addPatentType.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addPatentType(patentType p) {
		
		return publicCreditService.insertPatentType(p);
	}
	
	/**
	 * 修改专利分类
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upPatentType.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upPatentType(patentType p) {
		
		return publicCreditService.updatePatentType(p);
	}
	
	
	
	/**
	 * 删除专利分类
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delPatentType.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delPatentType(Integer id) {
		
		return publicCreditService.deletePatentType(id);
	}
	
	
	
	
	
	
	/**
	 * 显示行政监管信用记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectAdministrative.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectAdministrative(int id) {
		
		return publicCreditService.selectAdministrative(id);
	}
	
	
	/**
	 * 增加行政监管信用记录
	 * @param a
	 * @return
	 */
	@RequestMapping(value = "addAdministrative.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addAdministrative(administrative a) {
		
		return publicCreditService.insertAdministrative(a);
	}
	
	/**
	 * 修改行政监管信用记录
	 * @param a
	 * @return
	 */
	@RequestMapping(value = "upAdministrative.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upAdministrative(administrative a) {
		
		return publicCreditService.updateAdministrative(a);
	}
	
	
	/**
	 * 删除行政监管信用记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delAdministrative.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delAdministrative(int id) {
		
		return publicCreditService.deleteAdministrative(id);
	}
	
	
	
	
	
	
	/**
	 * 显示司法监管信用记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectJudicial.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectJudicial(int id) {
		
		return publicCreditService.selectJudicial(id);
	}
	
	
	/**
	 * 增加司法监管信用记录
	 * @param j
	 * @return
	 */
	@RequestMapping(value = "addJudicial.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addJudicial(judicial j) {
		
		return publicCreditService.insertJudicial(j);
	}
	
	/**
	 * 修改司法监管信用记录
	 * @param j
	 * @return
	 */
	@RequestMapping(value = "upJudicial.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upJudicial(judicial j) {
		
		return publicCreditService.updateJudicial(j);
	}
	
	
	/**
	 * 删除司法监管信用记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delJudicial.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delJudicial(int id) {
		
		return publicCreditService.deleteJudicial(id);
	}
	
	
	
	
	
	
	
	/**
	 * 显示招标投标活动中的违法及处罚
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectViolationOperation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectViolationOperation(int id) {
		
		return publicCreditService.selectViolationOperation(id);
	}
	
	
	/**
	 * 增加招标投标活动中的违法及处罚
	 * @param v
	 * @return
	 */
	@RequestMapping(value = "addViolationOperation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addViolationOperation(violationOperation v) {
		
		return publicCreditService.insertViolationOperation(v);
	}
	
	/**
	 * 修改招标投标活动中的违法及处罚
	 * @param v
	 * @return
	 */
	@RequestMapping(value = "upViolationOperation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upViolationOperation(violationOperation v) {
		
		return publicCreditService.updateViolationOperation(v);
	}
	
	
	/**
	 * 删除招标投标活动中的违法及处罚
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delViolationOperation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delViolationOperation(int id) {
		
		return publicCreditService.deleteViolationOperation(id);
	}
	
	
	
	
	
	
	
	/**
	 * 显示信贷记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectCreditLoan.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectCreditLoan(int id) {
		
		return publicCreditService.selectCreditLoan(id);
	}
	
	
	/**
	 * 增加信贷记录
	 * @param c
	 * @return
	 */
	@RequestMapping(value = "addCreditLoan.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addCreditLoan(creditLoan c) {
		
		return publicCreditService.insertCreditLoan(c);
	}
	
	/**
	 * 修改信贷记录
	 * @param c
	 * @return
	 */
	@RequestMapping(value = "upCreditLoan.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upCreditLoan(creditLoan c) {
		
		return publicCreditService.updateCreditLoan(c);
	}
	
	
	/**
	 * 删除信贷记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delCreditLoan.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delCreditLoan(int id) {
		
		return publicCreditService.deleteCreditLoan(id);
	}
	
	
	
	
	
	
	
	/**
	 * 显示软件著作权
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectCopyright.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectCopyright(int id) {
		
		return publicCreditService.selectCopyright(id);
	}
	
	
	/**
	 * 增加软件著作权
	 * @param c
	 * @return
	 */
	@RequestMapping(value = "addCopyright.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addCopyright(copyright c) {
		
		return publicCreditService.insertCopyright(c);
	}
	
	/**
	 * 修改软件著作权
	 * @param c
	 * @return
	 */
	@RequestMapping(value = "upCopyright.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upCopyright(copyright c) {
		
		return publicCreditService.updateCopyright(c);
	}
	
	
	/**
	 * 删除软件著作权
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delCopyright.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delCopyright(int id) {
		
		return publicCreditService.deleteCopyright(id);
	}
	
	
	
	
	
	
	
	
	
	
	/**
	 * 显示企业荣誉
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectEnterpriseHonor.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectEnterpriseHonor(int id) {
		
		return publicCreditService.selectEnterpriseHonor(id);
	}
	
	
	/**
	 * 增加企业荣誉
	 * @param e
	 * @return
	 */
	@RequestMapping(value = "addEnterpriseHonor.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addEnterpriseHonor(enterpriseHonor e) {
		
		return publicCreditService.insertEnterpriseHonor(e);
	}
	
	/**
	 * 修改企业荣誉
	 * @param e
	 * @return
	 */
	@RequestMapping(value = "upEnterpriseHonor.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upEnterpriseHonor(enterpriseHonor e) {
		
		return publicCreditService.updateEnterpriseHonor(e);
	}
	
	
	/**
	 * 删除企业荣誉
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delEnterpriseHonor.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delEnterpriseHonor(int id) {
		
		return publicCreditService.deleteEnterpriseHonor(id);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/**
	 * 显示社会公益
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectPublicWelfare.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectPublicWelfare(int id) {
		
		return publicCreditService.selectPublicWelfare(id);
	}
	
	
	/**
	 * 增加社会公益
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addPublicWelfare.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addPublicWelfare(publicWelfare p) {
		
		return publicCreditService.insertPublicWelfare(p);
	}
	
	/**
	 * 修改社会公益
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upPublicWelfare.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upPublicWelfare(publicWelfare p) {
		
		return publicCreditService.updatePublicWelfare(p);
	}
	
	
	/**
	 * 删除社会公益
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delPublicWelfare.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delPublicWelfare(int id) {
		
		return publicCreditService.deletePublicWelfare(id);
	}
}
